import request from "../request";

export function getFileList({ params, method }) {
  return request({ url: "/fileList", method: method, params: params });
}

export function setFileNameApi({ params, method }) {
  return request({ url: "/setFileName", method: method, params: params });
}

export function getFileLink({ params, method }) {
  return request({ url: "/download", method: method, data: params });
}

export async function downloadFromOss({ params, callback }) {
  return request({
    url: params.url,
    responseType: "arraybuffer",
    onDownloadProgress: callback,
  });
}

export async function uploadFile({ params }) {
  return request({ url: "/upload", data: params });
}

export function addFolder({ params }) {
  return request({ url: "/mkDir", data: params });
}

export function moveToBin({ params }) {
  return request({ url: "/deleteTemp", data: params });
}

export function deleteForever({ params }) {
  return request({ url: "/deleteForever", data: params });
}

export function recover({ params }) {
  return request({ url: "/recoverFile", data: params });
}
